<?php
/*
	用户提现接口
 */
require('../database/db.php');
$mysql=new mysql();
// 需传参数 
$userid=$_REQUEST['userid'];
$money=$_REQUEST['money'];
// 需传参数 end
if (!empty($userid) && $money>0) {
	$sql = "select money from user where userid=".$userid;
	$userMoney = $mysql->getOne($sql);
	if ($userMoney>=$money) {
		$sql = "UPDATE user SET `money`=`money`-'".$money."' where userid=".$userid;
		$mysql->query($sql);
		if ($mysql->affected_rows()>0) {
			$arr = array('code' => 100, 'tip' =>'提现成功');
		}else{
			$arr = array('code' => 200, 'tip' =>'提现失败');
		}
	}else{
		$arr = array('code' => 400, 'tip' =>'用户余额不足');
	}
}else{
	$arr = array('code' => 300, 'tip' =>'参数传入有误,必传参数:用户id=>userid;提现金额=>money');
}
echo json_encode($arr);
?>